package practice;

import javax.naming.Name;
import java.util.Comparator;
import java.util.FormatFlagsConversionMismatchException;
import java.util.Scanner;
import java.util.TreeSet;

/**
 * @ProjectName: ybxy6
 * @Titile: TreeSetPractice
 * @Author: 86183
 * @Description: TODO
 */
public class TreeSetPractice {
    public static void main(String[] args) {
        TreeSet<Person> ts = new TreeSet<>(new Comparator<Person>() {
            @Override
            public int compare(Person o1, Person o2) {
                return o1.getName().compareTo(o2.getName());
            }

        });
        Scanner scanner = new Scanner(System.in);
        for (int i = 0; i < 3; i++) {
            System.out.println("请输入第" + (i + 1) + "个学生的信息：");
            System.out.println("请输入姓名：");
            String name = scanner.next();
            System.out.println("请输入语文成绩：");
            double chinese = scanner.nextDouble();
            System.out.println("请输入数学成绩：");
            double math = scanner.nextDouble();
            System.out.println("请输入英语成绩：");
            double english = scanner.nextDouble();
            Person person = new Person(name, chinese, math, english);
            ts.add(person);
        }
        for (Person person : ts) {
            System.out.println(person);
        }
    }
}